package com.bige.mall.service.impl;

import java.util.List;
import com.bige.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bige.mall.mapper.MallGoodsMapper;
import com.bige.mall.domain.MallGoods;
import com.bige.mall.service.IMallGoodsService;

/**
 * 商品skuService业务层处理
 * 
 * @author bige
 * @date 2022-02-13
 */
@Service
public class MallGoodsServiceImpl implements IMallGoodsService 
{
    @Autowired
    private MallGoodsMapper mallGoodsMapper;

    /**
     * 查询商品sku
     * 
     * @param goodsId 商品sku主键
     * @return 商品sku
     */
    @Override
    public MallGoods selectMallGoodsByGoodsId(Long goodsId)
    {
        return mallGoodsMapper.selectMallGoodsByGoodsId(goodsId);
    }

    /**
     * 查询商品sku列表
     * 
     * @param mallGoods 商品sku
     * @return 商品sku
     */
    @Override
    public List<MallGoods> selectMallGoodsList(MallGoods mallGoods)
    {
        return mallGoodsMapper.selectMallGoodsList(mallGoods);
    }

    /**
     * 根据商品Id查询商品sku列表
     *
     * @param productId 商品Id
     * @return 商品sku集合
     */
    @Override
    public List<MallGoods> selectMallGoodsListByProductId(Long productId) {
        return mallGoodsMapper.selectMallGoodsListByProductId(productId);
    }

    /**
     * 新增商品sku
     * 
     * @param mallGoods 商品sku
     * @return 结果
     */
    @Override
    public int insertMallGoods(MallGoods mallGoods)
    {
        mallGoods.setCreateTime(DateUtils.getNowDate());
        return mallGoodsMapper.insertMallGoods(mallGoods);
    }

    /**
     * 批量新增商品sku
     *
     * @param mallGoodsList 商品sku
     * @return 结果
     */
    @Override
    public int insertMallGoodsList(List<MallGoods> mallGoodsList) {
        return mallGoodsMapper.insertMallGoodsList(mallGoodsList);
    }

    /**
     * 修改商品sku
     * 
     * @param mallGoods 商品sku
     * @return 结果
     */
    @Override
    public int updateMallGoods(MallGoods mallGoods)
    {
        mallGoods.setUpdateTime(DateUtils.getNowDate());
        return mallGoodsMapper.updateMallGoods(mallGoods);
    }

    /**
     * 批量删除商品sku
     * 
     * @param goodsIds 需要删除的商品sku主键
     * @return 结果
     */
    @Override
    public int deleteMallGoodsByGoodsIds(Long[] goodsIds)
    {
        return mallGoodsMapper.deleteMallGoodsByGoodsIds(goodsIds);
    }

    /**
     * 根据商品Id删除商品sku
     *
     * @param productId 商品Id主键
     * @return 结果
     */
    public int deleteMallGoodsByProductId(Long productId){
        return mallGoodsMapper.deleteMallGoodsByProductId(productId);
    }

    /**
     * 根据商品Id数组删除商品sku
     *
     * @param productIds 商品Id主键
     * @return 结果
     */
    @Override
    public int deleteMallGoodsByProductIds(Long[] productIds) {
        return mallGoodsMapper.deleteMallGoodsByProductIds(productIds);
    }

    /**
     * 删除商品sku信息
     * 
     * @param goodsId 商品sku主键
     * @return 结果
     */
    @Override
    public int deleteMallGoodsByGoodsId(Long goodsId)
    {
        return mallGoodsMapper.deleteMallGoodsByGoodsId(goodsId);
    }
}
